import json

from django.http import JsonResponse


def log_data(request):
    data = json.loads(request.body)
    list_1 = []
    b = open("E:/lapi_project/lapi_app/log/all.log", "r", encoding='UTF-8')
    for line in list(b)[::-1]:
        if len(list_1) < data["count"]:
            list_1.append(str(line).replace('\n', '"').replace('\"', '"'))
    return JsonResponse({
        "code": 200,
        "message": "获取日志信息成功",
        "log_data": list_1
    })
